package com.cxhc.system.service.app.impl;

import java.util.List;
import com.cxhc.system.domain.app.CmComment;
import com.cxhc.system.mapper.app.CmCommentMapper;
import com.cxhc.system.mapper.app.CmInfomMapper;
import com.cxhc.system.service.app.ICmCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 评论Service业务层处理
 * 
 * @author Dhq
 * @date 2024-09-24
 */
@Service
public class CmCommentServiceImpl implements ICmCommentService
{
    @Autowired
    private CmCommentMapper cmCommentMapper;

    @Autowired
    private CmInfomMapper cmInfomMapper;

    /**
     * 查询评论
     * 
     * @param id 评论主键
     * @return 评论
     */
    @Override
    public CmComment selectCmCommentById(Long id)
    {
        return cmCommentMapper.selectCmCommentById(id);
    }

    /**
     * 查询评论列表
     * 
     * @param cmComment 评论
     * @return 评论
     */
    @Override
    public List<CmComment> selectCmCommentList(CmComment cmComment)
    {

        return cmCommentMapper.selectCmCommentList(cmComment);
    }

    /**
     * 新增评论
     * 
     * @param cmComment 评论
     * @return 结果
     */
    @Override
    public int insertCmComment(CmComment cmComment)
    {
        int i = cmCommentMapper.insertCmComment(cmComment);
        cmInfomMapper.updateCommentTotalById(cmComment.getTargetId());
        return i;
    }

    /**
     * 修改评论
     * 
     * @param cmComment 评论
     * @return 结果
     */
    @Override
    public int updateCmComment(CmComment cmComment)
    {
        return cmCommentMapper.updateCmComment(cmComment);
    }

    /**
     * 批量删除评论
     * 
     * @param ids 需要删除的评论主键
     * @return 结果
     */
    @Override
    public int deleteCmCommentByIds(Long[] ids)
    {
        return cmCommentMapper.deleteCmCommentByIds(ids);
    }

    /**
     * 删除评论信息
     * 
     * @param id 评论主键
     * @return 结果
     */
    @Override
    public int deleteCmCommentById(Long id)
    {
        return cmCommentMapper.deleteCmCommentById(id);
    }
}
